.class public Lcom/vividsolutions/jts/index/quadtree/Key;
.super Ljava/lang/Object;
.source "Key.java"


# instance fields
.field private env:Lcom/vividsolutions/jts/geom/Envelope;

.field private level:I

.field private pt:Lcom/vividsolutions/jts/geom/Coordinate;


# direct methods
.method public constructor <init>(Lcom/vividsolutions/jts/geom/Envelope;)V
    .locals 1

    .line 64
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 58
    new-instance v0, Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-direct {v0}, Lcom/vividsolutions/jts/geom/Coordinate;-><init>()V

    iput-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->pt:Lcom/vividsolutions/jts/geom/Coordinate;

    const/4 v0, 0x0

    .line 59
    iput v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->level:I

    const/4 v0, 0x0

    .line 61
    iput-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->env:Lcom/vividsolutions/jts/geom/Envelope;

    .line 65
    invoke-virtual {p0, p1}, Lcom/vividsolutions/jts/index/quadtree/Key;->computeKey(Lcom/vividsolutions/jts/geom/Envelope;)V

    return-void
.end method

.method private computeKey(ILcom/vividsolutions/jts/geom/Envelope;)V
    .locals 13

    .line 97
    invoke-static {p1}, Lcom/vividsolutions/jts/index/quadtree/DoubleBits;->powerOf2(I)D

    move-result-wide v0

    .line 98
    iget-object p1, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->pt:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/Envelope;->getMinX()D

    move-result-wide v2

    div-double/2addr v2, v0

    invoke-static {v2, v3}, Ljava/lang/Math;->floor(D)D

    move-result-wide v2

    mul-double v2, v2, v0

    iput-wide v2, p1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 99
    iget-object p1, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->pt:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-virtual {p2}, Lcom/vividsolutions/jts/geom/Envelope;->getMinY()D

    move-result-wide v2

    div-double/2addr v2, v0

    invoke-static {v2, v3}, Ljava/lang/Math;->floor(D)D

    move-result-wide v2

    mul-double v2, v2, v0

    iput-wide v2, p1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    .line 100
    iget-object v4, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->env:Lcom/vividsolutions/jts/geom/Envelope;

    iget-object p1, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->pt:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v5, p1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    add-double v7, v5, v0

    iget-wide v9, p1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    add-double v11, v9, v0

    invoke-virtual/range {v4 .. v12}, Lcom/vividsolutions/jts/geom/Envelope;->init(DDDD)V

    return-void
.end method

.method public static computeQuadLevel(Lcom/vividsolutions/jts/geom/Envelope;)I
    .locals 4

    .line 50
    invoke-virtual {p0}, Lcom/vividsolutions/jts/geom/Envelope;->getWidth()D

    move-result-wide v0

    .line 51
    invoke-virtual {p0}, Lcom/vividsolutions/jts/geom/Envelope;->getHeight()D

    move-result-wide v2

    cmpl-double p0, v0, v2

    if-lez p0, :cond_0

    goto :goto_0

    :cond_0
    move-wide v0, v2

    .line 53
    :goto_0
    invoke-static {v0, v1}, Lcom/vividsolutions/jts/index/quadtree/DoubleBits;->exponent(D)I

    move-result p0

    add-int/lit8 p0, p0, 0x1

    return p0
.end method


# virtual methods
.method public computeKey(Lcom/vividsolutions/jts/geom/Envelope;)V
    .locals 1

    .line 85
    invoke-static {p1}, Lcom/vividsolutions/jts/index/quadtree/Key;->computeQuadLevel(Lcom/vividsolutions/jts/geom/Envelope;)I

    move-result v0

    iput v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->level:I

    .line 86
    new-instance v0, Lcom/vividsolutions/jts/geom/Envelope;

    invoke-direct {v0}, Lcom/vividsolutions/jts/geom/Envelope;-><init>()V

    iput-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->env:Lcom/vividsolutions/jts/geom/Envelope;

    .line 87
    iget v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->level:I

    invoke-direct {p0, v0, p1}, Lcom/vividsolutions/jts/index/quadtree/Key;->computeKey(ILcom/vividsolutions/jts/geom/Envelope;)V

    .line 89
    :goto_0
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v0, p1}, Lcom/vividsolutions/jts/geom/Envelope;->contains(Lcom/vividsolutions/jts/geom/Envelope;)Z

    move-result v0

    if-nez v0, :cond_0

    .line 90
    iget v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->level:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->level:I

    .line 91
    iget v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->level:I

    invoke-direct {p0, v0, p1}, Lcom/vividsolutions/jts/index/quadtree/Key;->computeKey(ILcom/vividsolutions/jts/geom/Envelope;)V

    goto :goto_0

    :cond_0
    return-void
.end method

.method public getEnvelope()Lcom/vividsolutions/jts/geom/Envelope;
    .locals 1

    .line 70
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->env:Lcom/vividsolutions/jts/geom/Envelope;

    return-object v0
.end method

.method public getLevel()I
    .locals 1

    .line 69
    iget v0, p0, Lcom/vividsolutions/jts/index/quadtree/Key;->level:I

    return v0
.end method
